package cn.zyjblogs.starter.common.entity.dto;

import cn.zyjblogs.starter.common.entity.constant.CommonConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;

/**
 * @author zhuyijun
 */
@ApiModel(value = "cn.zyjblogs.starter.common.entity.dto.PageDto", description = "分页查询dto")
@ToString
public class PageDto {
    @ApiModelProperty(value = "当前页数", dataType = "Integer", required = true, example = "1")
    @NotNull(message = "当前页数不能为空")
    @DecimalMin(message = "最少为1", value = "1")
    private Integer page;

    @ApiModelProperty(value = "每页条数", dataType = "Integer", required = true, example = "10")
    @NotNull(message = "每页条数不能为空")
    @DecimalMin(message = "最少为1", value = "1")
    private Integer limit;

    public PageDto() {
    }

    public PageDto(Integer page, Integer limit) {
        this.page = page == null ? CommonConstant.DEFAULT_PAGE : page;
        this.limit = limit == null ? CommonConstant.DEFAULT_LIMIT : limit;
    }

    public Integer getPage() {
        return page;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setPage(Integer page) {
        this.page = page == null ? CommonConstant.DEFAULT_PAGE : page;
    }

    public void setLimit(Integer limit) {
        this.limit = limit == null ? CommonConstant.DEFAULT_LIMIT : limit;
    }

}
